package com.texaco.chapasFutbol.menu;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener;
import org.andengine.entity.scene.menu.item.IMenuItem;
import org.andengine.entity.scene.menu.item.TextMenuItem;

import android.opengl.GLES20;

import com.texaco.chapasFutbol.R;
import com.texaco.chapasFutbol.entidades.Game;
import com.texaco.chapasFutbol.resources.Resources;

public class EndGameMenu extends ChapasMenuScene implements IOnMenuItemClickListener {

	private static final int OPTION_EXIT = 0;
	private static final int OPTION_CANCEL = 1;
	
	public EndGameMenu(Game game, Camera camera){
		super(game, camera);

		/*
		 * Menu Item Leave Online
		 */
		final TextMenuItem miExit = new TextMenuItem(OPTION_EXIT,
				this.game.getActivity().getFontMap().get(Resources.FONT_OPTIONS),
				game.getActivity().getText(R.string.tMenuItemExit),
				game.getActivity().getVertexBufferObjectManager());
		miExit.setBlendFunction(GLES20.GL_SRC_ALPHA, 
				GLES20.GL_ONE_MINUS_SRC_ALPHA);
		this.addMenuItem(miExit);

		/*
		 * Menu Item Leave Online
		 */
		final TextMenuItem miCancel = new TextMenuItem(OPTION_CANCEL, 
				this.game.getActivity().getFontMap().get(Resources.FONT_OPTIONS),
				game.getActivity().getText(R.string.tMenuItemCancel),
				game.getActivity().getVertexBufferObjectManager());
		miCancel.setBlendFunction(GLES20.GL_SRC_ALPHA, 
				GLES20.GL_ONE_MINUS_SRC_ALPHA);
		this.addMenuItem(miCancel);
		
		this.buildAnimations();
		this.setBackgroundEnabled(false);
		this.setOnMenuItemClickListener(this);
	}

	public boolean onOptionSelected(MenuScene pMenuScene, IMenuItem pMenuItem,
			float pMenuItemLocalX, float pMenuItemLocalY) {
		boolean done = true;
		
		switch (pMenuItem.getID()) {
		case OPTION_EXIT:
			game.finalizarJuego();
			game.loadSummaryScene();
			this.postActivateHud(false);
			// this.back();
			break;

		case OPTION_CANCEL:
			// this.back();
			break;

		default:
			done = false;
			break;
		}
		
		return done;
	}
	
	
}
